home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
dviware
/
dvi2pcl
/
drawchar.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-24
|
3KB
|
102 lines
/* $Log: drawchar.c,v $
* Revision 0.8 92/11/23 19:46:44 19:46:44 bt (Bo Thide')
* Fixed resolution bug. Portable downloading. Added/changed options. PJXL color support
*
* Revision 0.7 92/11/13 02:41:28 02:41:28 bt (Bo Thide')
* More bug fixes and improvements. Support for PaintJet XL
*
* Revision 0.6 92/11/10 21:47:44 21:47:44 bt (Bo Thide')
* Bug fixes. Added -R option. Better font handling.
*
* Revision 0.5 92/11/09 16:25:31 16:25:31 bt (Bo Thide')
* Rewrite of dospecial.c. Extended \special support
*
* Revision 0.4 92/11/08 02:45:47 02:45:47 bt (Bo Thide')
* Changed to portable bit manipulations. Replaced strrstr for non-POSIX compliant C. Fixed numerous bugs. Added support for more \special's.
*
* Revision 0.3 92/08/24 12:43:19 12:43:19 bt (Bo Thide')
* Fixed 8 bit (dc font) support.
*
* Revision 0.2 92/08/23 17:28:56 17:28:56 bt (Bo Thide')
* Source cleaned up. Changed certain function calls. Removed globals.
*
* Revision 0.1 92/08/22 23:58:47 23:58:47 bt (Bo Thide')
* First Release.
* */
#include <stdio.h>
#include "globals.h"
#include "pcl.h"
static char rcsid[] = "$Header: drawchar.c,v 0.8 92/11/23 19:46:44 bt Exp $";
/*
* On entrance to this routine, the character to be drawn will be in 'c', the
* font in use is pointed by the pointer '*font'. The external name by which
* the font is known in 'font->down'. The routine is also responsible for
* setting the printer to the correct location on the page ('hh' and 'vv')
*/
charfmt *drawchar(bitfile, c, hh, vv, resolution, device)
FILE *bitfile;
int c;
long hh, vv;
short resolution;
short device;
{
int i,j;
int pxl_bytes;
charfmt *u;
gcharfmt *g;
byte *p;
char drawrow[8];
#ifdef DEBUG
fprintf(stderr,"\ndrawchar: hh = %ld, vv = %ld,\n",hh, vv);
#endif
if(!h_posed && !v_posed) {
fprintf(bitfile, PCL4_MOVE_POSITION, hh + h_offset, vv + v_offset);
h_posed = v_posed = TRUE;
}
else if(!h_posed) {
fprintf(bitfile, PCL4_MOVE_H_POSITION, hh + h_offset);
h_posed = TRUE;
}
else if(!v_posed) {
fprintf(bitfile, PCL4_MOVE_V_POSITION, vv + v_offset);
v_posed = TRUE;
}
u = font->chr + c;
if(u->use_count > 0) {
/* Print downloaded character */
if(device == DEV_LJPLUS) {
putc(c > 32 ? c : c + 160, bitfile);
} else
if(c > 27)
putc(c, bitfile);
else
if(c==0 || c > 6 && c < 16 || c==27)
fprintf(bitfile, PCL4_TRANSP_MODE, c);
else
putc(c , bitfile);
} else {
/* Draw graphic raster pattern of character */
g = &(*gfont)[c];
p = g->pxl_pattern;
fputs(PCL4_PUSH, bitfile);
fprintf(bitfile, PCL4_MOVE_REL, g->x_offset, g->y_offset);
fprintf(bitfile, PCL4_RESOLUTION, resolution);
fputs(PCL4_START_RASTER, bitfile);
pxl_bytes = g->pxl_bytes;
sprintf(drawrow, PCL4_DRAWROW, pxl_bytes);
for(i = 0 ; i < g->pxl_rows ; i++) {
fputs(drawrow, bitfile);
for(j = 0 ; j < pxl_bytes ; j++)
putc(*p++, bitfile);
}
fputs(PCL4_END_RASTER, bitfile);
fputs(PCL4_POP, bitfile);
fprintf(bitfile, PCL4_MOVE_HREL, u->pxl_width);
}
return (u);
}